package com.example.eos.mapper;

import com.example.eos.bean.UserFollow;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserFollowMapper {

    @Select("select userid, followid, followtime from user_follow where userid = #{userid,jdbcType=VARCHAR}")
    List<UserFollow> findFollowByUserid(String userid);

    @Select("select userid, followid, followtime from user_follow where followid = #{userid,jdbcType=VARCHAR}")
    List<UserFollow> findFansByUserid(String userid);

    @Select("select userid, followid, followtime from user_follow where userid = #{userid,jdbcType=VARCHAR} and followid = #{followid,jdbcType=VARCHAR}")
    UserFollow findByUseridAndFollowid(@Param("userid") String userid, @Param("followid") String followid);

    @Insert("insert into user_follow (userfollowid, userid, followid, followtime) values (#{userfollowid,jdbcType=VARCHAR}, #{userid,jdbcType=VARCHAR}, #{followid,jdbcType=VARCHAR}, #{followtime})")
    void save(UserFollow userFollow);

    @Delete("delete from user_follow where userid = #{userid,jdbcType=VARCHAR} and followid = #{followid,jdbcType=VARCHAR}")
    void deleteByUseridAndFollowid(@Param("userid") String userid, @Param("followid") String followid);

}
